<?php

class FavoritedBookController extends Controller
{
	public function actionIndex()
	{
		$programming = $this->getBook(1);
		$java = $this->getBook(2);
		$cs = $this->getBook(3);
		$cp = $this->getBook(4);
		$joomla = $this->getBook(5);
		$graphic = $this->getBook(6);
		$game = $this->getBook(7);
		$other = $this->getBook(8);
		$this->render('index'
		, array(
		'programming'=>$programming,
		'java'=>$java,
		'cs'=>$cs,
		'cp'=>$cp,
		'joomla'=>$joomla,
		'graphic'=>$graphic,
		'game'=>$game,
		'other'=>$other,
		)
		);
	}
		public function getBook($genres)
	{
		$dataProvider=new CActiveDataProvider(Book::model(),
			array(
			'criteria'=>array(
				'condition'=>"idbook in (select idbook from book_genre where idgenre = $genres)",
				'order'=>'point desc, rateclick desc, downloadbookcount desc',
				'limit'=>8,
				),
			'pagination'=>array(
			'pageSize'=>8,
    ),
			));
			return $dataProvider;
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}